//
//  WHTool.swift
//  ttjx
//
//  Created by 文 on 2020/1/2.
//  Copyright © 2020 ttjx. All rights reserved.
//

import Foundation

public func stringRegularExpression(validateString:String,regex:String) -> String {
//        let regex = "([\\p{Sc}])\\w{8,12}([\\p{Sc}])"
        do {
            let regex: NSRegularExpression = try NSRegularExpression(pattern: regex, options: [])
            let matches = regex.matches(in: validateString, options: [], range: NSMakeRange(0, validateString.count))
            
            var data:[String] = Array()
            for item in matches {
                let string = (validateString as NSString).substring(with: item.range)
                data.append(string)
            }
            
//            DLLog(message: "regularExpressionTKL:\(data)")
            if data.count > 0 {
                return  data[0]
            }else{
                return ""
            }
        }
        catch {
//            DLLog(message: "regularExpressionTKL:nulldddd")
            return ""
        }
    }
